import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/global.css'
import 'font-awesome/css/font-awesome.css'
import {postResquest,getResquest,putResquest,deleteResquest} from "@/utils/api";
import {initMenu} from "@/utils/menu";


Vue.use(ElementUI)

Vue.prototype.postResquest = postResquest;
Vue.prototype.putResquest = putResquest;
Vue.prototype.getResquest = getResquest;
Vue.prototype.deleteResquest = deleteResquest;

router.beforeEach((to, from, next) => {
    if(window.sessionStorage.getItem('tokenStr')){
      initMenu(router,store);
      next();
    }else {
      if(to.path == '/'){
        next();
      }
    }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')